package com.news.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.news.entity.News;
import com.news.service.NewsService;

/**
 * Servlet implementation class showNews
 */
@WebServlet("/showNews")
public class ShowNews extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int newstyle=0;
		String style=request.getParameter("newstype");
		if(style!=null){
			newstyle=Integer.parseInt(style);
		}
		List<News> news=new ArrayList<News>();
		NewsService newsService=new NewsService();
		news=newsService.querynews(newstyle);
		request.setAttribute("news", news);
		request.getRequestDispatcher("/jsp/homePage.jsp").forward(request, response);
	}
}
